/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tesoreria.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.general.bc.PersonaNaturalFacadeLocal;
import org.cip.esymons.general.be.PersonaNatural;

/**
 *
 * @author Administrador
 */
public class PersonaNaturalDelegate {
    private PersonaNaturalFacadeLocal local;

    public PersonaNaturalDelegate() {
        local = lookupPersonaNaturalFacade();
    }

        public void create(PersonaNatural personaNatural) {
        local.create(personaNatural);
    }

    public void edit(PersonaNatural personaNatural) {
        local.edit(personaNatural);
    }

    public void remove(PersonaNatural personaNatural) {
        local.remove(personaNatural);
    }

    public PersonaNatural find(Object id) {
        return local.find(id);
    }

    public List<PersonaNatural> findAll() {
        return local.findAll();
    }

    public PersonaNatural buscarXDni(String dni) {
          return local.buscarXDni(dni);
    }

    private PersonaNaturalFacadeLocal lookupPersonaNaturalFacade() {
        try {
            Context c = new InitialContext();
            return (PersonaNaturalFacadeLocal) c.lookup("java:comp/env/PersonaNaturalFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
